home *** CD-ROM | disk | FTP | other *** search
- Path: news.internex.net.au!usenet
- From: sultan@connexus.apana.org.au (Jon Hornstein)
- Newsgroups: comp.lang.c
- Subject: Re: Help with a very weird C problem
- Date: Sat, 06 Apr 1996 04:38:44 GMT
- Organization: connexus.apana.org.au
- Message-ID: <4k2tdl$ft4@preeda.internex.net.au>
- References: <31620c87.184254741@199.171.83.2>
- NNTP-Posting-Host: dialin-16.internex.net.au
- X-Newsreader: Forte Free Agent 1.0.82
-
- With the briefest of looks at the code this function
-
-
- >char *PkunzipDir(char *curdir,char *name2,char *file)
- >{
- >char pkunzip2[120] = "pkunzip ";
- >strcat(pkunzip2,curdir);
- >strcat(pkunzip2,name2);
- >strcat(pkunzip2," ");
- >strcat(pkunzip2,curdir);
- >strcat(pkunzip2,file);
- >return(pkunzip2);
- >}
-
- should read
-
-
- char *PkunzipDir(char *curdir,char *name2,char *file)
- {
- static char pkunzip2[120] = "pkunzip ";
-
- strcat(pkunzip2,curdir);
- strcat(pkunzip2,name2);
- strcat(pkunzip2," ");
- strcat(pkunzip2,curdir);
- strcat(pkunzip2,file);
- return(pkunzip2);
- }
-
-
- marty1@rbdc.rbdc.com (Jumping Jack Flash) wrote:
-
- >Ok here's the problem. This program works great. BUT when I'm in the
- >c:\windows\desktop\programs directory instead of running the pkunzip
- >program it just shells a command.com, then after I type exit it
- >displays the ending screen. Here's the code
-
- >#include <stdlib.h>
- >#include <conio.h>
- >#include <iostream.h>
- >#include <string.h>
- >#include <dir.h>
- >#include <process.h>
- >#include <stdio.h>
- >#include <errno.h>
- >#define TRUE 1
- >#define FALSE 0
-
- >char *PkunzipDir(char *curdir,char *name2,char *file);
- >char *Current_Directory(char *path);
-
- >int main(int argc, char **argv)
- >{
- >clrscr();
- >char drive[MAXDRIVE];
- >char dir[MAXDIR];
- >char file[MAXFILE];
- >char ext[MAXEXT];
- >char curdir[MAXPATH];
- >char *pkunzip_search;
- >struct ffblk ffblk;
- >int done, stat;
-
- >//Searches all current dos paths for pkunzip
- >pkunzip_search = searchpath("pkunzip.exe");
- >if(pkunzip_search == NULL)
- > {
- > clrscr();
- > cout << "PKUNZIP.EXE must be in your dos path!";
- > exit(EXIT_FAILURE);
- > }
-
- >//Gets Current Directory & searches for first .zip file
- >Current_Directory(curdir);
-
- >if(argc == 2)
- > {
- > done = findfirst(argv[1],&ffblk,0);
- > if(done)
- > {
- > clrscr();
- > cout << "No Zipped files in current Directory\n";
- > }
- > else
- > {
- > while (!done)
- > {
- > fnsplit(ffblk.ff_name,drive,dir,file,ext);
- > stat = mkdir(file);
- > if (!stat)
- > {
- > cout << "\n" << "Directory " << file
- ><< " created\n";
- > cout << "Unzipping Files into it\n";
-
- >system(PkunzipDir(curdir,ffblk.ff_name,file));
- > }
-
- > else
- > {
- > clrscr();
- > cout << "Unable to create directory "
- ><< file << "\n";
- > cout << "For zipped file " << file <<
- >ext;
- > }
- > done = findnext(&ffblk);
- > }
- > }
- > }
- > else//A1
- > {
- > done = findfirst("*.zip",&ffblk,0);
- > if(done)
- > {
- > clrscr();
- > cout << "No Zipped files in current Directory\n";
- > }
- > else//A2
- > {
- > while (!done)
- > {
- > fnsplit(ffblk.ff_name,drive,dir,file,ext);
- > stat = mkdir(file);
- > if (!stat)
- > {
- > cout << "\n" << "Directory " << file
- ><< " created\n";
- > cout << "Unzipping Files into it\n";
-
- >system(PkunzipDir(curdir,ffblk.ff_name,file));
- > }
- > else
- > {
- > clrscr();
- > cout << "Unable to create directory "
- ><< file << "\n";
- > cout << "For zipped file " << file <<
- >ext;
- > }
- > done = findnext(&ffblk);
- > }//Ends While
- > }//Ends Else A2
- > }//End Else A1
- >cout <<"\n" << "This program is Freeware\n";
- >cout << "Written by Marty A. Lineberry\n";
- >cout << "Internet address marty1@rbdc.rbdc.com\n";
- >cout << "End of Program\n";
- >return 0;
- >}
-
-
-
- >char *PkunzipDir(char *curdir,char *name2,char *file)
- >{
- >char pkunzip2[120] = "pkunzip ";
- >strcat(pkunzip2,curdir);
- >strcat(pkunzip2,name2);
- >strcat(pkunzip2," ");
- >strcat(pkunzip2,curdir);
- >strcat(pkunzip2,file);
- >return(pkunzip2);
- >}
-
- >//**********************************************************
- >//* Used to get the current Drive & Directory *
- >//**********************************************************
- >char *Current_Directory(char *path)
- >{
- > strcpy(path, "X:\\"); /* fill string with form of response:
- >X:\ */
- > path[0] = 'A' + getdisk(); /* replace X with current drive
- >letter */
- > getcurdir(0, path+3); /* fill rest of string with current
- >directory */
- > if(strlen(path) > 3) /* Puts ending / if not root directory */
- > {
- > strcat(path,"\\");
- > }
- > return(path);
- >}
-
-
-
-
-
-
-